﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Bill;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class ReportBill : UserControl
    {
       
        private BillLogic billBll;
        private static ReportBill instance;
        public static ReportBill Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ReportBill();
                }
                return instance;
            }
        }
        public ReportBill()
        {
            billBll = new BillLogic();
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            dgvBill.AutoGenerateColumns = false;
            btnSearch_Click(null, null);
            SPACommon.SetDataGridStyle(dgvBill);
            SPACommon.ShowSummary(dgvBill);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            DateTime from = dtpFrom.Value.Date;
            DateTime to = dtpTo.Value.Date.AddDays(1).AddSeconds(-1.0);
            string whereStr = string.Format(" where T_Bill.AddTime between #{0}# and #{1}#  ", from, to);
            dgvBill.DataSource = billBll.GetBillReport(whereStr);
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            SPACommon.ExportToExcel(dgvBill, "客户开单统计");
        }
    }
}
